const mongoose = require('mongoose')
const { DB_URL, DB_PASSWORD, DB_USERNAME } = require('../config')
const logger = require('../logger')

  ; (async function connectToMongoDB() {
    try {
      await mongoose.connect(DB_URL, {
        user: DB_USERNAME,
        pass: DB_PASSWORD,
        dbName: 'wechat_pay',
      })
      logger.info('MongoDB connected Sucess')
    } catch (error) {
      logger.error('Error connecting to MongoDB:', error.message)
    }
  })()